package com.boss.salary.service.impl;

import com.boss.common.entity.PageDTO;
import com.boss.common.util.DateUtils;
import com.boss.framework.dto.PaginationDTO;
import com.boss.salary.dao.IPersonSalaryExtDao;
import com.boss.salary.entity.PersonSalaryExt;
import com.boss.salary.service.IPersonSalaryExtService;
import com.boss.sys.utils.SysUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PersonSalaryExtServiceImpl implements IPersonSalaryExtService {

    /**
     * 引入日志框架常量
     */
    private final static Logger logger = LoggerFactory.getLogger(PersonSalaryExtServiceImpl.class);


    @Autowired
    private IPersonSalaryExtDao dao;

    @Override
    public PageDTO<PersonSalaryExt> queryPersonSalaryExtPage(PaginationDTO paginationDTO) {
        List<PersonSalaryExt> list = dao.queryPersonSalaryExtPage(paginationDTO);
        int total = dao.queryPersonSalaryExtTotal();
        PageDTO<PersonSalaryExt> pageDTO = new PageDTO<>();
        pageDTO.setRows(list);
        pageDTO.setTotal(total);
        return pageDTO;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void savePersonSalaryExt(PersonSalaryExt personSalaryExt) {
        personSalaryExt.setId(SysUtils.generateGuid());
        personSalaryExt.setCreateTime(String.valueOf(DateUtils.getCurrentTimeStamp()));
        personSalaryExt.setUpdateTime(String.valueOf(DateUtils.getCurrentTimeStamp()));
        personSalaryExt.setIsDeleted(0);
        dao.savePersonSalaryExt(personSalaryExt);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updatePersonSalaryExt(PersonSalaryExt personSalaryExt) {
        personSalaryExt.setUpdateTime(String.valueOf(DateUtils.getCurrentTimeStamp()));
        dao.updatePersonSalaryExt(personSalaryExt);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deletePersonSalaryExt(String id) {
        dao.deletePersonSalaryExt(id);
    }
}
